package base_demo.demo3;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //通过实现Callable接口,可以定义返回值
        //1.创建类并实现Callable接口
        MyCallable mc = new MyCallable();
        //2.创建Future的实现类FutureTask来获取到Callable的返回值
        FutureTask<Integer> ft = new FutureTask<>(mc);
        //3.将获取到的值给线程
        Thread t = new Thread(ft);
        t.start();
        Integer n = ft.get();
        System.out.println(n);

    }
}
